<template>
	<!-- 平台公告 -->
	<view class="notice">
		<!-- #ifdef APP-PLUS -->
		<top-set></top-set>
		<tab-top fixed="true" title="平台公告"></tab-top>
		<!-- #endif -->
		<view class="box">
			<view class="notice_item" v-for="(item,index) in items" 
			:key="index" @tap="enterItem(item)">
				<image class="item_img" :src="imgDomain + item.article_cover+'?imageView2/1/w/660/h/276'" mode=""></image>
				<view class="content">
					<view class="text">
						<view class="text_title">{{item.article_main_title}}</view>
						<view class="text_abstract">{{item.article_subhead}}</view>
					</view>
					<view class="icon">
						<image class="icon_img" src="/static/icon/arrows-r.png"></image>
					</view>
				</view>
				<view class="item_time">
					<view class="time">{{item.create_time | dateFrm }}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	let page = 1;
	import moment from "moment"
	export default {
	
		data(){
			return {
				items:[],
				imgDomain:this.appConfig().oss_url+'/' 
			}
		},
		filters:{
			dateFrm:function(time){
				let jsTime = time * 1000;
				return moment(jsTime).format('YYYY-MM-DD');
			}
		},
		onLoad(){
			this.getData();
		},
		methods: {
			enterItem(e){
				//console.log(e)
				let data = {
					id:e.id,
					article_main_title:e.article_main_title,
					article_cover:e.article_cover,
					create_time:e.create_time
				}
				uni.navigateTo({
					url:'/pages/user/notice/notice_item?obj='+JSON.stringify(data)
				})
			},
			getData(){
				this.req({
					url:'both/article',
					method:'get',
					data:{
						article_position:this.isLogin().type,
						ac_id:"notice",
						page:page,
						limit:10
					}
				},
				(res)=>{
					uni.stopPullDownRefresh();
					if(res.data.status == 1) {
						console.log(res); 
						this.items = res.data.data.data;
					}else{
						uni.showToast({
							title:'没有更多信息了',
							icon:'none'
						})
					}
				},
				(res)=>{
					uni.stopPullDownRefresh();
				})
			},
			/**
			 * 下拉刷新
			 */
			onPullDownRefresh(){
				page = 1;
				this.getData();
				
			},
			 
			/**
			 * 上拉加载
			 */
			onReachBottom(){
				page ++;
				this.req({
					url:'both/article',
					method:'get',
					data:{
						article_position:this.isLogin().type,
						page:page,
						limit:10
					}
				},
				(res)=>{
					if(res.data.status == 1) {
						this.items = this.items.concat(res.data.data.data);
					}else{
						uni.showToast({
							title:'没有更多信息了',
							icon:'none'
						})
					}
				},
				(res)=>{
					
				})
				
			}
		}
	}
</script>

<style lang="scss" scoped>
.notice{
	font-family: PingFang-SC-Medium;
	font-weight: normal;
	font-stretch: normal;
	letter-spacing: 0px;
	color: #333333;
	.box{
		padding: 40upx 45upx;
		width: 660upx;
		.notice_item{
			width: 660upx;
			height: 460upx;
			background-color: #ffffff;
			box-shadow: 0upx 2upx 10upx 0upx rgba(0, 0, 0, 0.1);
			border-radius: 8upx;
			margin-bottom: 38upx;
			.item_img{
				width: 660upx;
				height: 276upx;
				background-color: #535353;
				border-radius: 8upx 8upx 0upx 0upx;
				display: block;
			}
			.content{
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 20upx 30upx 0upx 30upx; 
				.text{
					.text_title{
						font-size: 32upx;
						line-height: 56upx;
					}
					.text_abstract{
						width: 20em;
						font-size: 24upx;
						line-height: 52upx;
						color: #999999;
						overflow:hidden;
						white-space:nowrap;
						text-overflow:ellipsis;
						word-wrap: break-word;
					}
				}
				.icon{
					.icon_img{
						width: 12upx;
						height: 22upx;
						display: block;
					}
				}
			} 
			.item_time{
				padding: 0 30upx 18upx 30upx; 
				font-size: 20upx;
				line-height: 44upx;
				color: #999999;
				.time{
					border-top: 1upx solid #e5e5e5;
				}
			}
		}
	}
}
</style>
